package com.focus.xyz.other.pages.tpytb;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.Select;

/**
 * Created by chenmeng on 2016/3/30.
 */
public class AddCustInfoPage {

    @FindBy(xpath = "//input[@name='applyName']")
    private WebElement insCustName;
    @FindBy(xpath = "//select[@name='applyCert']")
    private WebElement insCustCardType;
    @FindBy(xpath = "//input[@name='applyCerc']")
    private WebElement insCustCardNo;
    @FindBy(xpath = "//select[@name='applySex']")
    private WebElement insCustGender;
    @FindBy(xpath = "//input[@name='applyBirthday']")
    private WebElement insCustBirthDate;
    @FindBy(xpath = "//*[@id=\"add\"]")
    private WebElement addCustBtn;

    @FindBy(xpath = "//*[@id=\"datatable\"]/tbody/tr[2]")
    private WebElement custRow;
    @FindBy(xpath = "//*[@id=\"butlist\"]")
    private WebElement confirmBtn;

    /*public AddCustInfoPage(WebDriver driver) throws Exception{
        PageFactory.initElements(driver,this);
    }*/

    public void inputCustInfo(String custName) throws Exception{
        this.insCustName.clear();
        this.insCustName.sendKeys(custName);
    }

    //移动到工具类
    public void selectByValue(WebElement e,String dest) throws Exception{
        Select select = new Select(e);
        select.selectByValue(dest);
    }

    public void selectCardType(String dest) throws Exception{
        selectByValue(this.insCustCardType,dest);
    }

    public void selectGender(String dest) throws Exception{
        selectByValue(this.insCustGender,dest);
    }

    public void inputCustCardNo(String custNo) throws Exception{
        this.insCustCardNo.clear();
        this.insCustCardNo.sendKeys(custNo);
    }

    public void inputBirthDate(String date) throws Exception{
        this.insCustBirthDate.clear();
        this.insCustBirthDate.sendKeys(date);
    }

    public void clickAdd() throws Exception{
        this.addCustBtn.click();
    }

    public void clickCustRow() throws Exception{
        this.custRow.click();
    }

    public void clickConfirmBtn() throws Exception{
        this.confirmBtn.click();
    }


}
